<template>
	<view>
		<view class="card" v-for="(item,index) in formDataList" :key="index">
			<view class="title_box">
				<text>房源：{{item.nickName}}</text>
				<image src="https://hosue-omo.oss-cn-shenzhen.aliyuncs.com/assets/rightIcon.png" mode=""></image>
			</view>
			<view class="title_1">
				评价内容：
			</view>
			<view class="content">
				<view class="">
					{{item.content}}
				</view>

			</view>
			<view class="time_box">
				<image src="/pagesA/static/details/time.svg" mode=""></image>
				<text>评价时间：{{item.createTime}}</text>
			</view>
		</view>
		<view style="width: 100%;height: 200rpx;" v-if="formDataList.length > 0"></view>
		<view class="main dis" style="z-index: 9999;height: 80vh;" v-else>
			<view style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
				<image src="https://hosue-omo.oss-cn-shenzhen.aliyuncs.com/assets/noData.png" mode="aspectFit" style="width: 200rpx;height: 200rpx;"></image>
				<text>暂无数据</text>
			</view>
		</view>
		<view class="bottom_box">
			<view class="add_btn" @click="handleClick">
				新增评论
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue';
	import {
		commentsList
	} from './js/api.js'
	import {
		onReachBottom,
		onPullDownRefresh
	} from '@dcloudio/uni-app'
	import { onShow } from '@dcloudio/uni-app'
	const handleClick = () => {
		uni.navigateTo({
			url: '/pagesA/addEvaluate/addEvaluate'
		})
	}
	const paramsData = reactive({
		pageNum: 1,
		pageSize: 10
	})
	const isReach = ref(true)
	const formDataList = ref([])
	const getCommentsList = async () => {
		let res = await commentsList(paramsData)
		console.log(res)
		let list = res.data.data.list
		if (paramsData.pageNum == 1) {
			formDataList.value = list
		} else {
			formDataList.value = formDataList.value.concat(list)
		}
		// 刷新完成后关闭下拉刷新状态
		uni.stopPullDownRefresh();
		if (list.length < 10) isReach.value = false
	}

	onReachBottom(() => {
		// console.log('上拉触底')
		if (!isReach.value) return
		paramsData.pageNum++
		getCommentsList()
	})
	onPullDownRefresh(() => {
		paramsData.pageNum = 1
		getCommentsList()
	})
	onMounted(() => {
		
	})
	onShow(()=>{
		getCommentsList()
	})
</script>
<style>
	page {
		background: #F6F6F6 !important;
	}
</style>
<style lang="less" scoped>
	.card {
		padding: 30rpx;
		margin-top: 16rpx;
		background: #FFFFFF;

		.title_box {
			display: flex;
			justify-content: space-between;
			padding: 0 24rpx;
			align-items: center;
			height: 80rpx;
			background: #F7FAFD;
			border-radius: 4px;

			text {
				font-family: PingFangSC-Semibold;
				font-size: 28rpx;
				color: #000000;
				line-height: 36rpx;
				font-weight: 600;
			}

			image {
				width: 14rpx;
				height: 28rpx;
			}
		}

		.title_1 {
			font-family: PingFangSC-Regular;
			font-size: 24rpx;
			color: #333333;
			letter-spacing: 0;
			line-height: 42rpx;
			font-weight: 400;
			margin-top: 16rpx;
		}

		.content {
			font-family: PingFangSC-Regular;
			font-size: 24rpx;
			color: #666666;
			letter-spacing: 0;
			line-height: 42rpx;
			font-weight: 400;
			margin-top: 16rpx;
		}

		.time_box {
			display: flex;
			align-items: center;
			margin-top: 16rpx;

			image {
				width: 28rpx;
				height: 28rpx;
				margin-right: 8rpx;
			}

			text {
				font-family: PingFangSC-Regular;
				font-size: 24rpx;
				color: #333333;
				letter-spacing: 0;
				line-height: 42rpx;
				font-weight: 400;
			}
		}
	}

	.bottom_box {
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 30rpx 0 60rpx 0;
		background: #FFFFFF;
		width: 100%;

		.add_btn {
			width: 626rpx;
			height: 90rpx;
			line-height: 90rpx;
			background-image: linear-gradient(270deg, #F1B13F 0%, #F8D648 100%);
			border-radius: 50rpx;
			font-family: PingFangSC-Regular;
			font-size: 32rpx;
			color: #FFFFFF;
			text-align: center;
			font-weight: 400;
		}
	}
</style>